package com.cudex.negocio.beans;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;

/**
 * @author Nicolas Bordenave
 * @date 22/11/2011
 * @version 1.0
 */

@Embeddable
public class FacturaPK implements Serializable {

	private static final long serialVersionUID = 5536289364197305635L;

	@Column(name = "Serie", nullable = false)
	private String serie;

	@Column(name = "Numero", nullable = false)
	private int numero;

	public FacturaPK() {

	}

	public FacturaPK(String serie, int numero) {
		this.serie = serie;
		this.numero = numero;
	}

	public String getSerie() {
		return serie;
	}

	public void setSerie(String serie) {
		this.serie = serie;
	}

	public int getNumero() {
		return numero;
	}

	public void setNumero(int numero) {
		this.numero = numero;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + numero;
		result = prime * result + ((serie == null) ? 0 : serie.hashCode());
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (!(obj instanceof FacturaPK)) {
			return false;
		}
		FacturaPK other = (FacturaPK) obj;
		if (numero != other.numero) {
			return false;
		}
		if (serie == null) {
			if (other.serie != null) {
				return false;
			}
		} else if (!serie.equals(other.serie)) {
			return false;
		}
		return true;
	}

}
